package com.cecsmsserve.service.impl;

import com.cecsmsserve.entity.Report;
import com.cecsmsserve.mapper.ReportMapper;
import com.cecsmsserve.service.IReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cecsmsserve.util.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 王郝浠
 * @since 2024-05-20
 */
@Service
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements IReportService {

    @Autowired
    ReportMapper reportMapper;

    @Override
    public CommonResult selectByuId(int uId) {
        List<Report> list=reportMapper.selectByuId(uId);
        CommonResult result=new CommonResult(list);
        if(list.size()==0||list==null){
            result.setNotFound();
        }
        return result;
    }

    @Override
    public CommonResult insert(Report report) {
        report.setId(null);
        int i=reportMapper.insert(report);
        CommonResult result=new CommonResult(report);
        if(i<0){
            result.setNotInserted();
        }
        return result;
    }

    @Override
    public CommonResult update(Report report) {
        int i=reportMapper.updateById(report);
        CommonResult result=new CommonResult(i);
        if(i<=0){
            result.setNotUpdate();
        }
        return result;
    }
}
